package com.ihrm.common.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private Boolean success;
    private Integer code;
    private String message;
    private T data;

    public Result(ResultCode resultCode){
        this.code = resultCode.code;
        this.success = resultCode.success;
        this.message = resultCode.message;
    }

    public Result(ResultCode resultCode, T data){
        this.code = resultCode.code;
        this.success = resultCode.success;
        this.message = resultCode.message;
        this.data = data;
    }

    public Result(Integer code, String message, Boolean success){
        this.code = code;
        this.message = message;
        this.success = success;
    }

    public static Result SUCCESS(){
        return new Result(ResultCode.SUCCESS);
    }

    public static Result SUCCESS(Object data){
        return new Result(ResultCode.SUCCESS, data);
    }

    public static Result FAIL(){
        return new Result(ResultCode.FAIL);
    }

    public static Result ERROR(){
        return new Result(ResultCode.SERVER_ERROR);
    }


}
